/**
 * 仅用于 FormRender.vue 内部组件（FetchForm.vue、PropertyForm.vue 组件）的数据互通用，不参与业务逻辑
 */
import { VuexModule, Module, Mutation, getModule } from 'vuex-module-decorators'
import store from '@/store'

interface IColumn {
  name: string
  [key: string]: any
}
interface IDatasetPipelineDataList {
  dataset: Array<{
    id: number
    name: string
    tableName: string
  }>
  pipeline: Array<{
    id: number
    name: string
    tableName: string
  }>
}
@Module({ dynamic: true, namespaced: true, name: 'FormRenderStore', store })
class FormRenderStore extends VuexModule {
  public columnList: IColumn[] = [] // FormRender 当前数据集下获取的字段列表
  public datasetPipelineDataList: IDatasetPipelineDataList = {
    dataset: [],
    pipeline: [],
  } // 导入和pipeline的数据集

  @Mutation
  public setColumnList(list: IColumn[]) {
    this.columnList = list
  }

  @Mutation
  public setDatasetPipelineDataList(list: IDatasetPipelineDataList) {
    this.datasetPipelineDataList = list
  }
}

export default getModule(FormRenderStore)
